package com.sl.biz.modular.print.dao.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.print.dao.domain.entity.PrintConfigContentDO;
import com.sl.biz.modular.print.dao.mapper.PrintConfigContentMapper;
import com.sl.biz.modular.print.dao.service.PrintConfigContentDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class PrintConfigContentDaoServiceImpl extends ServiceImpl<PrintConfigContentMapper, PrintConfigContentDO> implements PrintConfigContentDaoService {
    @Override
    public Boolean removeByPrintId(String printId) {
        LambdaQueryWrapper<PrintConfigContentDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PrintConfigContentDO::getPrintId, printId);
        return super.remove(lambdaQueryWrapper);
    }

    @Override
    public PrintConfigContentDO getByPrintId(String printId) {
        LambdaQueryWrapper<PrintConfigContentDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PrintConfigContentDO::getPrintId, printId);
        return CollUtil.get(super.list(lambdaQueryWrapper), 0);
    }
}
